package com.bounds.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.bounds.dao.ProductDao;
import com.bounds.entity.Product;
import com.bounds.entity.Pager;

@SuppressWarnings("serial")
public class ProductAction extends BaseAction {
	private Product product;
	private List<Product> products;
	private Pager<Product> page;
	@Autowired
	private ProductDao productDao;

	public String list(){
		products = productDao.qryProducts(product);
		return "list";
	}
	
	public String listForPage(){
		page = this.productDao.qryProductsForPager(product, getPageNo(), getPageSize());
		return "page";
	}
	
	public String add(){
		this.productDao.addProduct(product);
		return "goBack";
	}
	
	public String delete(){
		this.productDao.deleteProduct(product.getId());
		return "goBack";
	}
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public List<Product> getProducts() {
		return products;
	}

	public Pager<Product> getPage() {
		return page;
	}
}
